package org.unv.mozhi.dao;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import org.unv.mozhi.entity.MMsg;

@Repository
@Transactional
public class MsgDAOImpl implements MsgDAO {
	@Autowired
	private SessionFactory sessionFactory;

	@Transactional(readOnly = false)
	public boolean create(MMsg message) {
		sessionFactory.getCurrentSession().saveOrUpdate(message);
		return true;
	}

	@Transactional(readOnly = false)
	public boolean delete(MMsg message) {
		sessionFactory.getCurrentSession().delete(message);
		return true;
	}

	@Transactional(readOnly = false)
	public MMsg getMessage(Integer messageId) {
		return (MMsg)sessionFactory.getCurrentSession().get(MMsg.class, messageId);
	}

	@Transactional(readOnly = false)
	public List<MMsg> listMessage() {
		return (List<MMsg>)null;
	}

}
